<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>1111</h1>
    <div id="app"></div>
    <script>
        var state = {
            msg : "hello"
        }
        var result
        Object.defineProperty(state, "msg",{
            get(){
                console.log("数据被访问")
                console.log(result)
            },
            set(val){
                console.log("数据被修改")
                console.log(val)
                document.querySelector("#app").innerHTML = val
                result = val
            }
        })
    </script>
</body>
</html>